package com.ruoyi.web.controller.system;


import com.ruoyi.web.service.C2IntegrationFailedDistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/api/C2IntegrationFailedDist")
public class C2IntegrationFailedDistController {

    @Autowired
    private C2IntegrationFailedDistService integrationFailDtsService;

    /**
     * 获取所有负责方的失败次数统计
     * @return Map<String, Integer> 返回负责方及其失败次数
     */
    @GetMapping("/byAll")
    public ResponseEntity<Map<String, Integer>> getAllIntegrationFailures() {
        // 调用 Service 层方法获取负责方失败次数统计
        Map<String, Integer> statistics = integrationFailDtsService.getResponsiblePartyCount();

        // 返回统计结果，包装为 ResponseEntity
        return ResponseEntity.ok(statistics);
    }

    /**
     * 获取当前自然周负责方的失败次数统计
     * @return Map<String, Integer> 返回负责方及其当前自然周的失败次数
     */
    @GetMapping("/byWeek")
    public ResponseEntity<Map<String, Integer>> getCurrentWeekIntegrationFailures() {
        // 调用 Service 层方法获取当前自然月负责方失败次数统计
        Map<String, Integer> statistics = integrationFailDtsService.getCurrentWeekResponsiblePartyCount();

        // 返回统计结果，包装为 ResponseEntity
        return ResponseEntity.ok(statistics);
    }

    /**
     * 获取当前自然月负责方的失败次数统计
     * @return Map<String, Integer> 返回负责方及其当前自然月的失败次数
     */
    @GetMapping("/byMonth")
    public ResponseEntity<Map<String, Integer>> getCurrentMonthIntegrationFailures() {
        // 调用 Service 层方法获取当前自然月负责方失败次数统计
        Map<String, Integer> statistics = integrationFailDtsService.getCurrentMonthResponsiblePartyCount();

        // 返回统计结果，包装为 ResponseEntity
        return ResponseEntity.ok(statistics);
    }

    /**
     * 获取当前自然季度负责方的失败次数统计
     * @return Map<String, Integer> 返回负责方及其当前自然季度的失败次数
     */
    @GetMapping("/byQuarter")
    public ResponseEntity<Map<String, Integer>> getCurrentQuarterIntegrationFailures() {
        // 调用 Service 层方法获取当前自然月负责方失败次数统计
        Map<String, Integer> statistics = integrationFailDtsService.getCurrentQuarterResponsiblePartyCount();

        // 返回统计结果，包装为 ResponseEntity
        return ResponseEntity.ok(statistics);
    }

    /**
     * 获取当前自然年负责方的失败次数统计
     * @return Map<String, Integer> 返回负责方及其当前自然年的失败次数
     */
    @GetMapping("/byYear")
    public ResponseEntity<Map<String, Integer>> getCurrentYearIntegrationFailures() {
        // 调用 Service 层方法获取当前自然月负责方失败次数统计
        Map<String, Integer> statistics = integrationFailDtsService.getCurrentYearResponsiblePartyCount();

        // 返回统计结果，包装为 ResponseEntity
        return ResponseEntity.ok(statistics);
    }
}
